package com.itheima.danli2;

public class Singlan {
    private static Singlan singlan = new Singlan();

    //优化一：防止反射破坏单例
    private Singlan(){
        if (singlan != null){
            throw new RuntimeException("单例构造器禁止反射调用");
        }
    }
    public static Singlan getInstance(){
        return singlan;
    }
    //防止序列化破坏单例
    private Object readResolve(){
        return singlan;
    }
}
